package com.fan.shop.services;

import java.util.List;

import javax.inject.Inject;
import javax.inject.Named;

import org.springframework.transaction.annotation.Transactional;

import com.fan.shop.dao.RoleDao;
import com.fan.shop.domain.Role;

@Named("roleService")
@Transactional(readOnly = true)
public class RoleServiceImpl implements RoleService {

	@Inject
	@Named("roleDao")
	private RoleDao roleDao;
	
	
	@SuppressWarnings("rawtypes")
	public List getList() {
		return roleDao.getAllRoles();
	}

	public int getColumnsSize() {
		return roleDao.getColumnNames().size();
	}

	public Object copy(Object obj) {
		// TODO Auto-generated method stub
		return null;
	}

	public Role getRole(String username) {
		return roleDao.getRole(username);
	}

	public List<Role> getAllRoles() {
		return roleDao.getAllRoles();
	}

	public int getSize() {
		return roleDao.getSize();
	}

	@Transactional(readOnly = false)
	public void addRole(Role role) {
		roleDao.addRole(role);
	}
	@Transactional(readOnly = false)
	public void updateStock(Role role) {
		roleDao.updateStock(role);
	}
	@Transactional(readOnly = false)
	public void deleteRole(Role role) {
		roleDao.deleteRole(role);
	}

	public boolean hasRole(String username) {
		return roleDao.hasRole(username);
	}

	public List<String> getColumnNames() {
		return roleDao.getColumnNames();
	}

}
